package com.kust.smarthome.web.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kust.smarthome.web.dto.ShopDto;
import com.kust.smarthome.web.mapper.ShopMapper;
import com.kust.smarthome.web.model.Shop;
import com.kust.smarthome.web.service.IShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author iAuzre
 * @since 2021-07-09
 */
@Service
public class ShopServiceImpl extends ServiceImpl<ShopMapper, Shop> implements IShopService {

    @Autowired
    private ShopMapper shopMapper;

    @Override
    public boolean insert(Integer userId, Integer commodityId) {

        Shop shop = new Shop()
                .setUserId(userId)
                .setCommodityId(commodityId);

        return 1 == shopMapper.insert(shop);
    }

    @Override
    public List<ShopDto> getShopList(Integer userId) {

        return shopMapper.getShopList(userId);
    }
}
